package com.vip.elastic.service;

import com.vip.common.response.Result;
import com.vip.elastic.entity.DocumentBean;
import com.vip.elastic.model.dto.AddDocumentDto;

import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * description
 *
 * @author wgb
 * @date 2020/11/10 10:49
 */
public interface IDocumentBeanService {

    /**
     * 保存对象
     *
     * @param docBean
     */
    Result<String> save(AddDocumentDto docBean);

    /**
     * 批量保存
     *
     * @param list
     */
    Result<String> saveMultiDoc(List<AddDocumentDto> list);

    /**
     * 查询全部对象
     *
     * @return
     */
    Result<Iterator<DocumentBean>> findAll();

    /**
     * 统计
     *
     *
     * @param pageNo
     * @param pageSize
     * @param content
     * @param firstCode
     * @param secondCode
     * @param type
     * @return
     */
    Result<List<DocumentBean>> getList(Integer pageNo, Integer pageSize, String content, String firstCode, String secondCode, Integer type);

    /**
     * 根据给定的字段的值的分词查询分词中包含给定的值的文档
     *
     * @param value
     * @param field
     * @return
     */
    Result<Iterator<DocumentBean>> matchQuery(String field, String value);

    /**
     * 根据给定的字段的值的分词查询分词中包含给定的值的文档
     *
     * @param field
     * @param value
     * @return
     */
    Result<Iterator<DocumentBean>> commonTermsQuery(String field, String value);

    /**
     * 根据给定的字段的值的分词查询分词中包含给定的值的文档，匹配的字段分词所在位置必须和待查询的值的分词位置一致
     *
     * @param field
     * @param value
     * @return
     */
    Result<Iterator<DocumentBean>> matchPhraseQuery(String field, String value);

    /**
     * 根据给定的字段的值的分词查询分词中包含给定的值的文档，匹配的字段分词所在位置必须和待查询的值的分词位置一致，
     *
     * @param field
     * @param value
     * @return
     */
    Result<Iterator<DocumentBean>> matchPhrasePrefix(String field, String value);

    /**
     * 对子查询的结果做去重合并，score沿用子查询score的最大值
     *
     * @param field
     * @param value
     * @return
     */
    Result<Iterator<DocumentBean>> disMaxQuery(String field, String value);

    Result<Iterator<DocumentBean>> idsQuery(List<Long> ids);

    Result<Iterator<DocumentBean>> termQuery(String field, String value);

    Result<Iterator<DocumentBean>> fuzzyQuery(String field, String value, Integer fuzzy);

    Result<Iterator<DocumentBean>> prefixQuery(String field, String value);

    Result<Iterator<DocumentBean>> rangeQuery(String field, String gte, String lte);

    Result<Iterator<DocumentBean>> wildcardQuery(String field, String value);

    Result<Iterator<DocumentBean>> regexpQuery(String field, String regexp);

    Result<Iterator<DocumentBean>> queryStringQuery(List<String> fields, String value);

    Result<Iterator<DocumentBean>> simpleQueryStringQuery(List<String> fields, String value);

    Result<Iterator<DocumentBean>> boostingQuery(String field, String value);

    Result<Iterator<DocumentBean>> boolQuery(Map<String, List<String>> params);

    Result<Iterator<DocumentBean>> spanTermQuery(String field, String value);

    Result<Iterator<DocumentBean>> spanFirstQuery(String field, String value);

    Result<Iterator<DocumentBean>> spanNearQuery(String field, String value);

    Result<Iterator<DocumentBean>> spanNotQuery(String field, String value);

    Result<Iterator<DocumentBean>> spanOrQuery(String field, String value);

    Result<Iterator<DocumentBean>> spanWithinQuery(String field, String value);

    Result<Iterator<DocumentBean>> spanContainingQuery(String field, String value);

    Result<Iterator<DocumentBean>> spanMultiTermQueryBuilder(String field, String value);

    Result<Iterator<DocumentBean>> fieldMaskingSpanQuery(String field, String value);

    Result<Iterator<DocumentBean>> constantScoreQuery(String field, String value);

    Result<Iterator<DocumentBean>> functionScoreQueryNoFunction(String field, String value);

    Result<Iterator<DocumentBean>> functionScoreQuery(List<String> values);

    Result<Iterator<DocumentBean>> moreLikeThisQuery(List<String> values);

    Result<Iterator<DocumentBean>> nestedQuery(String field, String value);

    Result<Iterator<DocumentBean>> termsQuery(String fields, List<String> value);

    Result<Iterator<DocumentBean>> wrapperQuery(String value);

    Result<Iterator<DocumentBean>> typeQuery(String type);

    Result<Iterator<DocumentBean>> termsLookupQuery(String index, String type, String id, String field);

    Result<Iterator<DocumentBean>> scriptQuery(String value, String source);

    Result<Iterator<DocumentBean>> existsQuery(String field);

    Result<Iterator<DocumentBean>> multiMatchQuery(String value, String... fields);
}
